package io.light.frame.samples.generator.config;

import io.light.frame.dal.mybatis.generator.core.domain.clazz.Clazz;
import io.light.frame.dal.mybatis.generator.core.domain.mapper.Mapper;
import io.light.frame.dal.mybatis.generator.core.listener.GenerationListener;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author Ivan
 * @version 1.0.0
 * @date 2021-06-21 19:14
 */
@Component
public class TestListener implements GenerationListener {

    @Override
    public void onMapperReady(Mapper mapper, Clazz daoClazz) {
        String daoName = daoClazz.getName();
        daoName = daoName.substring(0, daoName.length() - "Mapper".length()) + "Dao";
        mapper.setDaoClazz(Clazz.of(daoName).apply(daoClazz));
    }
}
